Pod::Spec.new do |spec|
  spec.name         = "bdface-ios"
  spec.version      = "0.0.1"
  spec.summary      = "百度人脸SDK的CocoaPods集成"
  spec.description  = <<-DESC
  百度人脸识别SDK的CocoaPods集成方案，包含活体检测、人脸采集、特征比对等功能。
                   DESC
  spec.homepage     = "https://gitee.com/bandai/bdface-ios"
  spec.license      = { :type => "MIT", :file => "LICENSE" }
  spec.author       = { "宋朝阳" => "447231214@qq.com" }

  # 平台配置
  spec.platform     = :ios, "12.0"
  spec.requires_arc = true
  spec.static_framework = true
  
  # 源码配置
  spec.source       = { 
    :git => "https://gitee.com/bandai/bdface-ios.git", 
    :tag => "#{spec.version}" 
  }
  
  # 文件配置
  spec.preserve_paths = 'Frameworks/*.framework'
  spec.source_files = 'Classes/**/*.{h,m}'
  spec.public_header_files = [
    'Classes/Public/**/*.h'
  ]

  # 模块配置
  spec.module_name = nil
  spec.module_map = nil

  # 依赖配置
  spec.vendored_frameworks = 'Frameworks/IDLFaceSDK.framework'
  spec.frameworks = [
    "UIKit", "CoreGraphics", "CoreMedia", "AVFoundation",
    "CoreTelephony", "SystemConfiguration", "Accelerate",
    "Security", "Foundation"
  ]
  spec.libraries = "c++", "z", "sqlite3"

  # 编译设置
  spec.pod_target_xcconfig = {
    'HEADER_SEARCH_PATHS' => [
      '"${PODS_ROOT}/bdface-ios/Frameworks/IDLFaceSDK.framework/Headers"',
      '"${PODS_ROOT}/bdface-ios/Classes"'
    ].join(' '),
    'FRAMEWORK_SEARCH_PATHS' => '"${PODS_ROOT}/bdface-ios/Frameworks"',
    'OTHER_LDFLAGS' => '-framework IDLFaceSDK',
    'VALID_ARCHS' => 'arm64 armv7',
    'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386 x86_64',
    'DEFINES_MODULE' => 'YES'
  }

  # 子模块配置
  spec.subspec 'Core' do |core|
    core.source_files = 'Classes/Public/**/*.{h,m}'
    core.public_header_files = 'Classes/Public/**/*.h'
    core.dependency 'bdface-ios/IDLFaceSDK'
    core.xcconfig = {
      'HEADER_SEARCH_PATHS' => '"${PODS_ROOT}/bdface-ios/Frameworks/IDLFaceSDK.framework/Headers"'
    }
  end

  spec.subspec 'ProgressHUD' do |hud|
    hud.source_files = 'Classes/BDFaceProgressHUD/*.{h,m}'
    hud.public_header_files = 'Classes/BDFaceProgressHUD/*.h'
  end

  spec.subspec 'UI' do |ui|
    ui.source_files = 'Classes/UI/**/*.{h,m}'
    ui.resources = ['Resources/UI/*.bundle']
    ui.dependency 'bdface-ios/Core'
    ui.dependency 'bdface-ios/ProgressHUD'
    ui.xcconfig = {
      'HEADER_SEARCH_PATHS' => [
        '"${PODS_ROOT}/bdface-ios/Frameworks/IDLFaceSDK.framework/Headers"',
        '"${PODS_ROOT}/bdface-ios/Classes"'
      ].join(' ')
    }
  end

  spec.subspec 'IDLFaceSDK' do |sdk|
    sdk.vendored_frameworks = 'Frameworks/IDLFaceSDK.framework'
    sdk.source_files = 'Frameworks/IDLFaceSDK.framework/Headers/*.h'
    sdk.private_header_files = 'Frameworks/IDLFaceSDK.framework/Headers/*.h'
    sdk.preserve_paths = 'Frameworks/IDLFaceSDK.framework'
    sdk.xcconfig = { 
      'FRAMEWORK_SEARCH_PATHS' => '"${PODS_ROOT}/../Frameworks"',
      'OTHER_LDFLAGS' => '-framework IDLFaceSDK'
    }
    sdk.frameworks = 'Accelerate', 'Security', 'CoreTelephony'
  end

  # 添加隐私清单
  spec.resource = 'Assets/PrivacyInfo.xcprivacy'
end
